package com.gzx.qc.modular.voice.text.controller;

import com.gzx.qc.modular.voice.text.entity.GzxHtVoiceText;
import com.gzx.qc.modular.voice.text.service.GzxHtVoiceTextService;
import com.gzx.qc.modular.voice.text.service.impl.GzxHtVoiceTextServiceJobImpl;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import vip.xiaonuo.common.pojo.CommonResult;

import java.util.List;

/**
 * @author zjt
 * @description
 * @date 2025/2/5 17:41
 */
@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("/qc/voice/text")
public class GzxHtVoiceTextController {

    private final GzxHtVoiceTextService htVoiceTextService;

    private final GzxHtVoiceTextServiceJobImpl htVoiceTextServiceJob;

    /**
     * 根据CallID获取通话文本
     *
     * @param callId
     * @return
     */
    @GetMapping("/getTextByCallId/{callId}")
    public CommonResult<List<GzxHtVoiceText>> getTextByCallId(@PathVariable("callId") String callId) {
        return CommonResult.data(htVoiceTextService.getTextByCallId(callId));
    }

    /**
     * ai质检
     */
    @PostMapping("/aiScanner")
    public CommonResult<Void> aiScanner() {
        try {
            log.info("开始任务------>使用AI来判定是否违规");
            htVoiceTextServiceJob.aiScanner();
        } catch (Exception e) {
            log.error("使用AI来判定是否违规 ", e);
        }
        return CommonResult.ok();
    }
}
